#pragma once
#include "PathData.h"

class CSpreadsheet;
class CPhiGamma;
class CPathData;

class CRoomData : public CPathData
{
public:
    CRoomData(void);
    virtual ~CRoomData(void);

    // load data from spreadsheet to here
    virtual void load(const vector<CSpreadsheet*> &vSpreadsheet_ );
    // save changes into spreadsheets
    virtual void precompute();
    virtual void precomputeEachTrial();
    //virtual void updateOutput();
    virtual void updateOutput(int nJoyStickOff_=0);
    virtual bool trialFinished();
    virtual void clear();
    virtual void saveToFile();
    virtual void afterCompute();
    virtual bool preRunFinished();
    virtual void parser(const string& strCondition_, vector<int>* pvConds_ );
    virtual void computeEyePositionAndGazing(CMatrix<double>& mEye_,CMatrix<double>& mGazingPoint_,int nCurrentFrame_);

    //Helper
    void precomputePathDirect();
    //retriever
    const double& headingBoundDegree() const {return _dHeadingBound;}
          double& setHeadingBoundDegree()    {return _dHeadingBound;}
    //target
    const double& targetRadius() const {return _dTargetRadius;}
          double& setTargetRadius()    {return _dTargetRadius;}
    const double& infrontofFar() const {return _dInfrontofFar;}
          double& setInfrontofFar()    {return _dInfrontofFar;}
    const double& gazePerturbationAxisOffsetRad() const {return _dGazePerturbationAxisOffset;}
          double& setGazePerturbationAxisOffsetRad()    {return _dGazePerturbationAxisOffset;}
    const int& targetAlwaysOnTop () const {return _nTargetAlwaysOnTop;}
          int& setTargetAlwaysOnTop ()    {return _nTargetAlwaysOnTop;}
    const CMatrix<double>& targetColor() const {return _mTargetColor;}
          CMatrix<double>& setTargetColor()    {return _mTargetColor;}
    const CMatrix<double>& targetPostColor() const {return _mTargetPostColor;}
          CMatrix<double>& setTargetPostColor()    {return _mTargetPostColor;}
    const CMatrix<double>& targetPostPosition() const {return _mTargetPostPosition;}
          CMatrix<double>& setTargetPostPosition()    {return _mTargetPostPosition;}

    const double& headingOffset() const {return _dHeadingOffset;}
          double& setHeadingOffset()    {return _dHeadingOffset;}
    const double& gazeOffset() const {return _dGazeOffset;}
          double& setGazeOffset()    {return _dGazeOffset;}
    const vector<double>& headingOffsetBoundsDeg()  const { return _vHeadingOffsetBoundsDeg;}
          vector<double>& setHeadingOffsetBoundsDeg()     { return _vHeadingOffsetBoundsDeg;}
    const vector<double>& gazeOffsetBoundsDeg()  const { return _vGazeOffsetBoundsDeg;}
          vector<double>& setGazeOffsetBoundsDeg()     { return _vGazeOffsetBoundsDeg;}
    const CMatrix<double>& groundColor() const {return _mGroundColor;}
          CMatrix<double>& setGroundColor()    {return _mGroundColor;}
    const double& sphereDiscRadius() const {return _dSphereDiscRadius;}
          double& setSphereDiscRadius() {return _dSphereDiscRadius;}
    //disturbances
    CPhiGamma* phiGamma(int nControlOrder_) const 
    {
        if(nControlOrder_-1<(int)_vpPhiGamma.size())
            return _vpPhiGamma[nControlOrder_-1];
        else
            return 0;
    }
    void CheckOutputFile();
    virtual void fullOutputFileName(int nTrial_,QString* pFullOutputFileName_) const;

protected:
    vector<CPhiGamma*>      _vpPhiGamma;
    vector<double>          _vHeadingOffsetBoundsDeg;
    vector<double>          _vGazeOffsetBoundsDeg;

    double              _dHeadingBound;
    double              _dTargetRadius;
    double              _dTargetHeight;
    double              _dInfrontofFar;
    double              _dHeadingOffset;
    double              _dGazeOffset;
    double              _dGazePerturbationAxisOffset;
    double              _dSphereDiscRadius;

    int _nTargetAlwaysOnTop;
    CMatrix<double> _mTargetColor;
    CMatrix<double> _mTargetPostColor;
    CMatrix<double> _mGroundColor;
    CMatrix<double> _mTargetPostPosition;
    
};
